<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>投票页面</title>
    <link rel="stylesheet" type="text/css" th:href="@{/mystatic/bootstrap-3.4.1-dist/css/bootstrap.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/mystatic/bootstrap-3.4.1-dist/css/bootstrap-theme.css}"/>
</head>
<script type="text/javascript">
    function myhrefresult(subid){
        window.location.href="selectSubjectResultDetail?subid="+subid;
    }
    function checkFromVote(){
        var obj =  document.getElementsByName("vopid");
        //alert(obj);
        for(var i = 0 ; i < obj.length; i++){
            //alert(obj[i].checked);
            if(obj[i].checked == true){
                return true;//说明已经有选中的了选项
            }
        }
        //alert("请选择投票的选项");
        document.getElementById("infoerr").innerHTML="<span style='color:red;margin:5px;border:1px solid red;' >请选择投票的选项</span>";
        return false;
    }
</script>
</head>
<body>
<p th:replace="sessionuser :: ftest"></p><!--替换掉宿主元素-->
<div class="container-fluid" >
    <div class="row">
        <div class="col-md-2"></div>
        <div class="col-md-8">
            <h2 align="center" >投票页面 , <a th:href="@{/list}" >返回</a></h2>
            <h3 style="color: green;" >标题:[(${onevo.vs_title})]</h3>
            <h4 style="color: #cccccc" >共有[(${onevo.subcount})]个选项,已有[(${onevo.vicount})]个网友参加了投票</h4>
            <hr/>
            <div style="margin-left: 50px;" >
                <div id="infoerr" ></div>
                <form th:action="@{/itemvote}"  method="post" onsubmit="return checkFromVote()" >
                    <input type="hidden" name="vsid" th:value="${onevo.vssid}"  />
                    <input type="hidden" name="userid" th:value="${session.user.id}"  />
                    <div th:each="v,stat:${op}">
                        [(${stat.count})] , <input  th:type="${v.vs_type eq 1?'radio':'checkbox'}" name="vopid" th:utext="'&nbsp;&nbsp;'+${v.vo_option}+'<br/>'" th:value="${v.vo_id}" />
                    </div>
                    <!-- <input th:each="v,stat:${op}" th:type="${v.vs_type eq 1?'radio':'checkbox'}" name="vopid" th:utext="${v.vo_option}+'<br/>'" th:value="${v.vo_id}" />-->
                    <input type="submit" name="sub" value="确定投票" />
                    <input type="button"  th:onclick="myhrefresult('[(${onevo.vssid})]')"  name="sub" value="查看结果" />
                </form>
            </div>
        </div>
        <div  class="col-md-2"></div>
    </div>
</div>


</body>
</html>